package com.tedu._07sptingaop.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LoggerAspect {
    @Around(value = "execution(public boolean com.tedu._07sptingaop.aop.CarServiceImpl.*(..))")
    public Object AroundAdd(ProceedingJoinPoint joinPoint){
        Object proceed =null;
        try {
            proceed = joinPoint.proceed();
            System.out.println("开始添加购物车");

            if ((boolean)proceed ) {
                System.out.println("添加失败");
            }
            System.out.println("成功");
        } catch(Throwable e) {
            System.out.println("异常通知");
        } finally {
            System.out.println("操作完成");
        }
            return proceed;
    }
}
